//
//  TKIMChatDelegate.h
//  TKIM
//  发消息，重发消息，查询历史消息，
//  查询历史会话，删除历史消息，删除历史会话
//  Created by liupm on 15/11/24.
//  Copyright © 2015年 liupm. All rights reserved.
//


@protocol TKIMChatProtocol <NSObject>

@optional

/**
 *  @Author lpm, 15-09-16 16:09:04
 *
 *  @brief  发送消息
 *
 *  @param message
 */
- (void)sendMessage:(TKIMMessage *) msg;


/**
 *  @Author lpm, 15-09-16 16:09:04
 *
 *  @brief  重新发送消息
 *
 *  @param message
 */
- (void)resendMessage:(TKIMMessage *) msg;


/**
 *  @Author lpm, 15-09-16 16:09:04
 *
 *  @brief  发送已读回执消息
 *
 *  @param message
 */
- (void)sendAckedMessage:(TKIMMessage *) msg;


/**
 *  @Author lpm, 16-07-18 15:07:11
 *
 *  @brief  转发消息
 *
 *  @param msg
 */
-(void)forwardingMessage:(TKIMMessage *)msg;


/**
 *  @Author lpm, 15-11-25 18:11:21
 *
 *  @brief  删除一条消息
 *
 *  @param msg
 */
-(void)removeMessage:(TKIMMessage *)msg;

/**
 *  @Author lpm, 17-05-02 10:05:15
 *
 *  @brief  删除服务器的一条消息
 *
 *  @param msgId    消息ID
 *  @param targetId 目标用户ID
 *  @param callBack 回调
 */
-(void)removeMessageById:(NSString *)msgId targetId:(NSString *)targetId callBack:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 15-11-25 19:11:08
 *
 *  @brief  删除一条会话
 *
 *  @param msg
 */
-(void)removeConverse:(TKIMConverseMessage *)msg;


/**
 *  @Author lpm, 15-11-25 19:11:11
 *
 *  @brief  查询所有历史会话
 *
 *  @return
 */
-(NSMutableArray *)queryHisConverses;


/**
 *  @Author lpm, 15-11-26 10:11:25
 *
 *  @brief  查询用户的历史消息
 *
 *  @param userID 用户ID
 *
 *  @return
 */
-(NSMutableArray *)queryUserHisMessageByUserId:(NSString *)userID;



/**
 *  @Author lpm, 16-03-26 12:03:13
 *
 *  @brief  查询用户指定条数消息
 *
 *  @param limit 条数
 *
 *  @return
 */
-(NSMutableArray *)queryHisMessage:(NSInteger)limit;


/**
 *  @Author lpm, 16-03-26 12:03:46
 *
 *  @brief  查询包含某个关键字的消息
 *
 *  @param key   关键字
 *  @param limit 条数
 *
 *  @return
 */
-(NSMutableArray *)queryHisMessageContain:(NSString *)key limit:(NSInteger)limit;



/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询用户指定条数消息
 *
 *  @param limit 条数
 *  @param callBack 回调
 */
-(void)asyncQueryHisMessage:(NSInteger)limit callBack:(void(^)(NSMutableArray *array))callBack;


/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询包含某个关键字的消息
 *
 *  @param key   关键字
 *  @param limit 条数
 *
 */
-(void)asyncQueryHisMessageContain:(NSString *)key limit:(NSInteger)limit callBack:(void(^)(NSMutableArray *array))callBack;


/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询用户多条消息数据
 *
 *  @param userID   用户ID
 *  @param callBack 回调
 */
-(void)asyncQueryUserHisMessageByUserId:(NSString *)userID callBack:(void(^)(NSMutableArray *array))callBack;

-(void)asyncQueryUserHisMessageByUserIdAndGetCompliance:(NSString *)userID appkey:(NSString*)appkey callBack:(void(^)(NSMutableArray *array))callBack;


/** 删掉本地数据根据最大天数
 *  @param userID   用户ID
 *  @param maxDay   最大天数
 */
-(void)asyncDeleteUserHisMessageByUserId:(NSString *)userID maxDay:(NSInteger)maxDay;

/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询用户多条消息数据
 *
 *  @param userID   用户ID
 *  @param count  数量
 *  @param callBack 回调
 */
-(void)asyncQueryUserHisMessageByUserId:(NSString *)userID count:(NSInteger)count callBack:(void(^)(NSMutableArray *array))callBack;


/**
 *  @Author lpm, 15-11-26 18:11:19
 *
 *  @brief  查询房间的历史消息
 *
 *  @param roomId 房间ID
 *
 *  @return
 */
-(NSMutableArray *)queryRoomHisMessageById:(NSString *)roomId;


/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询房间的历史消息
 *
 *  @param roomId  房间ID
 *  @param callBack 回调
 */
-(void)asyncQueryRoomHisMessageById:(NSString *)roomId callBack:(void(^)(NSMutableArray *array))callBack;


/**
 *  @Author lpm, 15-12-09 16:12:24
 *
 *  @brief   查询用户的历史消息
 *
 *  @param userID 用户ID
 *  @param count  数量
 *
 *  @return
 */
-(NSMutableArray *)queryUserHisMessageByUserId:(NSString *)userID count:(NSInteger)count;


/**
 *  @Author lpm, 15-11-26 18:11:19
 *
 *  @brief  查询房间的历史消息
 *
 *  @param roomId 房间ID
 *  @param count  数量
 *
 *  @return
 */
-(NSMutableArray *)queryRoomHisMessageById:(NSString *)roomId count:(NSInteger)count;


/**
 *  @Author lpm, 15-11-26 18:11:44
 *
 *  @brief  异步查询房间的历史消息
 *
 *  @param roomId  房间ID
 *  @param count  数量
 *  @param callBack 回调
 */
-(void)asyncQueryRoomHisMessageById:(NSString *)roomId count:(NSInteger)count callBack:(void(^)(NSMutableArray *array))callBack;


/**
 *  @Author lpm, 15-11-25 19:11:11
 *
 *  @brief  根据名称查询会话
 *
 *  @return
 */
-(NSMutableArray *)queryHisConverseByName:(NSString *)name;


/**
 *  @Author lpm, 15-11-25 19:11:40
 *
 *  @brief  重置用户会话消息数据
 *
 *  @param userID 用户ID
 */
-(void)resetUserConverseCount:(NSString *)userID;


/**
 *  @Author lpm, 15-11-25 19:11:43
 *
 *  @brief  清空所有会话
 */
-(void)cleanAllConverse;


/**
 *  @Author lpm, 15-11-25 19:11:43
 *
 *  @brief  清空用户所有消息
 */
-(void)cleanUserMessage:(TKIMUser *)user;


/**
 *  @Author lpm, 16-07-27 16:07:26
 *
 *  @brief  从服务器请求用户会话列表
 *
 *  @param callBack
 */
-(void)loadConversationsFromServer:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 16:07:26
 *
 *  @brief  从服务器请求用户会话列表
 *
 *  @param callBack
 */
-(void)loadConversationsWithCountFromServer:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 16:07:26
 *
 *  @brief  从服务器请求用户会话列表
 *
 *  @param param    外部参数
 *  @param callBack
 */
-(void)loadConversationsWithCountFromServer:(NSMutableDictionary *)param callBack:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 17:07:27
 *
 *  @brief  从服务器请求用户历史消息
 *
 *  @param lastMessage 最后一条消息
 *  @param count   拉取的条数
 *  @param callBack
 */
-(void)loadUserHisMsgFromServer:(NSString *)userId startIndex:(NSInteger)startIndex count:(NSInteger )count :(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 17:07:27
 *
 *  @brief  从服务器请求群组历史消息
 *
 *  @param lastMessage 最后一条消息
 *  @param count   拉取的条数
 *  @param callBack
 */
-(void)loadGroupHisMsgFromServer:(NSString *)roomId startIndex:(NSInteger)startIndex count:(NSInteger )count :(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 16:07:26
 *
 *  @brief  同步用户的消息数到服务器
 *
 *  @param callBack
 */
-(void)syncUserMsgCountToServer:(NSInteger)msgCount callBack:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 17-05-02 14:05:48
 *
 *  @brief  同步消息数到服务器
 */
-(void)syncUserMsgCountToServer;


/**
 *  @Author lpm, 16-07-27 17:07:27
 *
 *  @brief  从服务器请求用户历史消息
 *
 *  @param lastMessage 最后一条消息
 *  @param count   拉取的条数
 *  @param callBack
 */
-(void)loadUserHisMsgFromServer:(NSString *)targetId timestamp:(NSTimeInterval)timestamp count:(NSInteger )count :(TKIMCallBack)callBack;


/**
 *  @Author lpm, 16-07-27 17:07:27
 *
 *  @brief  从服务器请求群组历史消息
 *
 *  @param lastMessage 最后一条消息
 *  @param count   拉取的条数
 *  @param callBack
 */
-(void)loadGroupHisMsgFromServer:(NSString *)targetId timestamp:(NSTimeInterval)timestamp count:(NSInteger )count :(TKIMCallBack)callBack;


/**
 *  @Author lpm, 17-12-28 10:12:26
 *
 *  @brief  上传消息轨迹
 *
 *  @param msgID    消息ID
 *  @param serialNo 业务流水号
 *  @param callBack 回调
 */
-(void)syncMsgTrace:(NSString *)msgID serialNo:(NSString *)serialNo callBack:(TKIMCallBack)callBack;


/**
 *  @Author lpm, 17-12-28 10:12:26
 *
 *  @brief  上传消息轨迹
 *
 *  @param msgs    消息列表
 *  @param callBack 回调
 */
-(void)syncMsgTraces:(NSArray <TKIMMessage *>*)msgs callBack:(TKIMCallBack)callBack;


@end
